<div class="crumb-wrap">
    <div class="crumb-list"> <i class="icon-font"></i>
        <a href="<?=site_url()?>">首页</a>
        <span class="crumb-step">&gt;</span>
        <a class="crumb-name" href="<?=site_url('order/manage')?>">订单管理</a>
        <span class="crumb-step">&gt;</span>
        <span>用户订单</span>
    </div>
</div>
<style type="text/css">
    .show_table th{
        text-align: center;
    }
</style>
<div class="result-wrap">
    <form action="/think/admin/system/save" method="post" id="myform" name="myform">
        <div class="config-items">
            <div class="config-title">
                <h1>
                    <i class="icon-font">&#xe014;</i>
                    用户信息
                </h1>
            </div>
            <div class="result-content">
                <table class="insert-tab show_table" width="90%">
                    <tr style="background: #f5f5f5">
                        <th width="150">用户ID</th>
                        <th>真实姓名</th>
                        <th>用户权限</th>
                        <th>联系手机</th>
                        <th>联系QQ</th>
                        <th>联系微信</th>
                        <th>邮箱</th>
                    </tr>
                    <tr>
                        <th><?=$uinfo['id']?></th>
                        <th><?=$uinfo['name']?></th>
                        <th><?=$ugroup['title']?></th>
                        <th><?=$uinfo['phone']?></th>
                        <th><?=$uinfo['qq']?></th>
                        <th><?=$uinfo['weixin']?></th>
                        <th><?=$uinfo['email']?></th>
                    </tr>
                </table>
                <table width="90%" class="insert-tab" style="margin-top: 10px">
                    <tr>
                        <th width="150">单位名称：</th>
                        <td><?= !$uinfo['company'] ? '(空)' : $uinfo['company']?></td>
                    </tr>
                    <tr>
                        <th width="150">联系地址：</th>
                        <td><?= !$uinfo['address'] ? '(空)' : $uinfo['address']?></td>
                    </tr>
                </table>
            </div>
        </div>

        <?php if(!empty($list_comm)):?>
        <div class="config-items">
            <div class="config-title">
                <h1>
                    <i class="icon-font">&#xe014;</i>
                    佣金信息
                </h1>
            </div>
            <div class="result-content">
                <table class="insert-tab show_table" width="90%">
                    <tr style="background: #f5f5f5">
                        <th>用户ID</th>
                        <th>登录帐号</th>
                        <th>真实姓名</th>
                        <th>佣金积分</th>
                        <th>用户权限</th>
                        <th>联系手机</th>
                        <th>联系邮箱</th>
                    </tr>
                    <?php foreach($list_comm as $k => $v):?>
                    <tr>
                        <th><?=$v['user_id']?></th>
                        <th><?=$v['user']['username']?></th>
                        <th><?=$v['uinfo']['name']?></th>
                        <th><?=$v['money']?> 元</th>
                        <th><?=$v['group']['title']?></th>
                        <th><?=$v['uinfo']['phone']?></th>
                        <th><?=$v['uinfo']['email']?></th>
                    </tr>
                    <?php endforeach;?>
                </table>
            </div>
        </div>
        <?php endif;?>

        <div class="config-items">
            <div class="config-title">
                <h1>
                    <i class="icon-font">&#xe00a;</i>
                    用户订单信息
                </h1>
            </div>
            <div class="result-content">
                <table class="insert-tab show_table" width="90%" style="margin-top: 10px">
                    <tr style="background: #f5f5f5">
                        <th width="150">订单编号</th>
                        <th>订单状态</th>
                        <th>订单积分</th>
                        <th>创建时间</th>
                        <th>更新时间</th>
                    </tr>
                    <tr>
                        <th><?=$res['id']?></th>
                        <th style="color:red"><?=$status[$res['status']]?></th>
                        <th><?=$res_par['price']?> 元</th>
                        <th><?=date('Y-m-d H:i:s',$res['create_time'])?></th>
                        <th><?=date('Y-m-d H:i:s',$res['update_time'])?></th>
                    </tr>
                </table>

                <table width="90%" class="insert-tab" style="margin-top: 10px">
                    <tr>
                        <th width="150">订单项目</th>
                        <td><?=$res_par['title']?> &nbsp;&nbsp;<a href="<?=site_url('parameters/show?pid='.$res_par['id'])?>" target="_blank">查看项目信息</a></td>
                    </tr>
                    <tr>
                        <th width="150">联系姓名</th>
                        <td><?=$res['user_name']?></td>
                    </tr>
                    <tr>
                        <th width="150">联系电话</th>
                        <td><?=$res['user_phone']?></td>
                    </tr>
                    <tr>
                        <th>系统备注</th>
                        <td><?=$res['remarks']?></td>
                    </tr>
                    <tr>
                        <th>用户备注</th>
                        <td><pre><?=$res['user_remarks']?></pre></td>
                    </tr>
                    <?php if($res['status'] == 6): ?>
                    <tr>
                        <th>积分退还备注</th>
                        <td style="color:red"><pre><?=$res['mess']?></pre></td>
                    </tr>
                    <?php endif;?>
                </table>
            </div>
            <div class="result-content" style="margin-top: 15px">
                <?php if($res['status'] == 4): ?>
                <a href="javascript:;" onclick="layer.alert('正在等待用户签收,禁止操作！ ',{icon:2})" class="btn btn6 mr10">订单完结</a>
                <?php endif;?>
                <?php if($res['status'] == 2): ?>
                <a href="javascript:;" onclick="acceptance(<?=$res['id']?>)" class="btn btn6 mr10 btn-primary">订单受理</a>
                <?php endif;?>
                <?php if(!empty($handie[$res['status']])): ?>
                <a href="javascript:;" onclick="order_processing('<?=$res['status']+1?>','<?=$handie[$res['status']]?>')" class="btn btn-primary btn6 mr10"><?=$handie[$res['status']]?></a>
                <?php endif;?>

                <?php if($res['status'] <= 2 ): ?>
                <a href="javascript:;" onclick="quit_order()" class="btn btn6 <?=$res['status'] == 1 ? 'btn-primary' :''?> mr10">取消订单</a>
                <?php endif;?>

                <a href="javascript:;" onclick="history.go(-1)" class="btn btn6 mr10">返回</a>
            </div>
        </div>

    </form>
</div>
<script type="text/javascript">
    layer.config({
        extend: 'extend/layer.ext.js'
    });

    //用户订单取消
    function quit_order(){
        layer.prompt({
            title: '输入订单取消理由：',
            formType: 2,
            maxlength: 100
        }, function(mess){
            $.post("<?=site_url('order/quit_order')?>",{oid:<?=$res['id']?>,mess:mess},function(data){
                if(data == 1){
                    layer.alert("操作成功！",{
                        icon:1,
                    },function(){
                        location.reload();
                    });
                }else{
                    layer.alert(data,{
                        icon:2,
                    });
                }
            });
        });
    }

    //订单处理
    function order_processing(status,mess){
        layer.confirm("是否将该订单状态改为：“"+mess+"”", {
            icon:0,
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post("<?=site_url('order/processing')?>",{oid:<?=$res['id']?>,status:status},function(data){
                if(data == 1){
                    layer.alert("操作成功！",{
                        icon:1,
                    },function(){
                        location.reload();
                    });
                }else{
                    layer.alert(data,{
                        icon:2,
                    });
                }
            });
        });
    }

    //订单受理
    function acceptance(oid){
        layer.confirm("受理订单后将分配订单资金，并且不允许取消，是否确定？", {
            icon:0,
            btn: ['确定','取消'] //按钮
        },function(){
            $.post("<?=site_url('order/acceptance')?>",{oid:<?=$res['id']?>},function(data){
                if(data == 1){
                    layer.alert("操作成功，请尽快处理订单！",{
                        icon:1,
                    },function(){
                        location.reload();
                    });
                }else{
                    layer.alert(data,{
                        icon:2,
                    });
                }
            });
        });
    }
</script>